package com.yjkf.zh.admin.controller;

import com.yjkf.zh.admin.model.SysDeviceEvent;
import com.yjkf.zh.admin.service.SysDeviceEventService;
import com.yjkf.zh.core.http.HttpResult;
import com.yjkf.zh.core.page.PageRequest;
import com.yjkf.zh.core.page.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(value="deviceEvent")
public class SysDeviceEventController {

    @Autowired
    private SysDeviceEventService sysDeviceEventService;

    @PostMapping(value = "/findAll")
    public HttpResult getPageAll(@RequestBody PageRequest pageRequest){
        int pageNum = pageRequest.getPageNum();
        int pageSize = pageRequest.getPageSize();

        return HttpResult.ok(sysDeviceEventService.findDeviceEventPage(pageNum,pageSize));
    }

    @GetMapping(value = "/findDeviceEventForIdentName")
    public HttpResult findDeviceEventForIdentName(@RequestParam String identName){
            return HttpResult.ok(sysDeviceEventService.findDeviceEventForIdentName(identName));
    }

    @PostMapping(value = "/saveDeviceEvent")
    public HttpResult saveDeviceEvent(@RequestBody SysDeviceEvent sysDeviceEvent){
        return HttpResult.ok(sysDeviceEventService.saveDeviceEvent(sysDeviceEvent));
    }
}
